#include <stdio.h>
#include <stdlib.h>

typedef short int bool;
#define true    1
#define false   0

#define MAX  1000

int stack[MAX];
int top = -1;

int head = 0;

int N = 0;
bool FLAG = false;

void init()
{
    top = -1;
}

bool isempty()
{
    if(top == -1)
    {
        return true;
    }
    return false;
}

bool isfull()
{
    if(top == MAX)
    {
        return true;
    }
    return false;
}

bool push(int val)
{
    if(isfull())
    {
        return false;
    }
    stack[++top] = val;
    return true;
}

bool pop(int* val)
{
    if(isempty())
    {
        *val = -1;
        return false;
    }
    *val = stack[top--];
    return true;
}

bool gettop(int* val)
{
    if(isempty())
    {
        *val = -1;
        return false;
    }
    *val = stack[top];
    return true;
}

void showsq()
{
    int i = 0;

    printf("stack:\t");
    for(i = 0; i <= top; i++)
    {
        printf("%d\t", stack[i]);
    }
    printf("\n");
    printf("queue:\t");

    for(i = head; i <= N; i++)
    {
        printf("%d\t", i);
    }

    printf("\n");
}

/*
1.将1到queue[0]之间的数压入.

2.将栈和输出序列的首端字母比较
    相同:将栈项项输出
    不同:
    1).若需输出项不在待输出项中,输出非法序列,结束.
    2).否则.将输出序列的项依次压入栈,直到栈顶端与待输出数相同,将栈首输出
3.重复2,直到queue空
4.如果栈为空,则合法序列,否则非法.
*/

//5 4 1 2 3
void check(int k)
{
    int i = 0;
    int val = 0;

    if(FLAG == false)
    {
        return;
    }

    for(i = head; i <= k && i <= N; i++)
    {
        push(i);
    }

    head = head <= k ? k +1 : head;

    //showsq();

    if(gettop(&val) == false)
    {
        printf("error\n");
    }
    if(val == k)
    {
        pop(&val);
    }
    else
    {
        FLAG = false;
    }

}

void prepare(int n)
{
    head = 1;
    init();
    FLAG = true;
}

int main()
{
    //freopen("bin\\debug\\in.txt", "r", stdin);
    int i = 0;
    int val = 0, flag = true;

    while(1)
    {
        scanf("%d", &N);
        if(N == 0)
        {
            break;
        }
        flag = true;
        while(flag)
        {
            prepare(N);
            for(i = 0; i < N; i++)
            {
                scanf("%d", &val);
                if(val == 0)
                {
                    flag = false;
                    break;
                }
                check(val);
            }
            if(flag && FLAG == true)
            {
                printf("Yes\n");
            }
            else if(flag && !FLAG)
            {
                printf("No\n");
            }
            else
            {
                printf("\n");
            }
        }

    }

    return 0;
}
